//
//  XJWalletSectionHeadView.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/5/23.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJWalletSectionHeadView.h"
@interface XJWalletSectionHeadView()
@property(nonatomic, strong) UIView *bgView;

@property(nonatomic, strong) UILabel *nameLabel;
@end

@implementation XJWalletSectionHeadView
//- (instancetype)init
//{
//    self = [super init];
//    if (self) {
//        [self addSubview:self.nameLabel];
//    }
//    return self;
//}
//
//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//
//    }
//    return self;
//}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
   self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView {
    [self.contentView addSubview:self.bgView];
    
    [self.bgView addSubview:self.nameLabel];
}
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = XJFONTSET_M(16);
    }
    return _nameLabel;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    
    /***
     备注
     UITableViewHeaderFooterView 自定义的话需要重写他自己的创建方法
     如果通过tableView注册区头的方式  init 和 initWitFrame 都不会走 ∴ 在那里面写的 addSubview 等于没写
     */
//    [self addSubview:self.nameLabel];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView.mas_left).offset(15);
    }];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}


- (void)configureWalletSectionHeadViewWithName:(NSString *)name {
    self.nameLabel.text = name;
}


@end
